This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 219
Mini Cart block > Update block registration to rely on a metadata file. #10168
Merged
nefeline
merged 2 commits into
trunk
from
enhance/register-mini-cart-block-with-json-metadata
Jul 12, 2023
Merged
Mini Cart block > Update block registration to rely on a metadata file. #10168
nefeline
merged 2 commits into
trunk
from
enhance/register-mini-cart-block-with-json-metadata
Jul 12, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nefeline
added
block: mini-cart
Issues related to the Mini-Cart block.
type: enhancement
The issue is a request for an enhancement.
labels
Jul 11, 2023
The release ZIP for this PR is accessible via:
TypeScript Errors Report
🎉 🎉 This PR does not introduce new TS errors. Script Dependencies ReportThere is no changed script dependency between this branch and trunk. This comment was automatically generated by the |
Size Change: +197 B (0%) Total Size: 1.35 MB
ℹ️ View Unchanged
|
Aljullu
approved these changes
Jul 12, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
block: mini-cart
Issues related to the Mini-Cart block.
type: enhancement
The issue is a request for an enhancement.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Ensure the mini-cart block uses the
block.json
metadata file as the canonical way to register the block type with both PHP (server-side) and JavaScript (client-side) as this has been the recommended approach for registering blocks since WordPress 5.8.The benefits of this change are highlighted in this post, which includes:
The block definition allows code sharing between JavaScript, PHP, and other languages when processing block types stored as JSON, and registering blocks with the block.json metadata file provides multiple benefits on top of it.
From a performance perspective, when themes support lazy loading assets, blocks registered with block.json will have their asset enqueuing optimized out of the box. The frontend CSS and JavaScript assets listed in the style or script properties will only be enqueued when the block is present on the page, resulting in reduced page sizes.
Furthermore, because the Block Type REST API Endpoint can only list blocks registered on the server, registering blocks server-side is recommended; using the
block.json
file simplifies this registration.The WordPress Plugins Directory can detect
block.json
files, highlight blocks included in plugins, and extract their metadata.Testing
User Facing Testing
WooCommerce Visibility
Changelog